package fanglimao.hyear2.registry;

import fanglimao.hyear2.HiddenYears2;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.item.AxeItem;
import net.minecraft.item.EnchantedGoldenAppleItem;
import net.minecraft.item.HoeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.StewItem;
import net.minecraft.item.SwordItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;

public class ModItems {
    public static final Item COPPER_COIN = new Item(new FabricItemSettings());
    public static final Item GOLD_COIN = new Item(new FabricItemSettings());
    public static final Item DIAMOND_COIN = new Item(new FabricItemSettings());
    // 燃料
    public static final Item FUEL_METAL = new Item(new FabricItemSettings().food(ModFoods.FUEL_METAL));
    public static final Item NIGHTMARE_FUEL_METAL = new Item(new FabricItemSettings());
    public static final Item FUEL_METAL_STICK = new Item(new FabricItemSettings().food(ModFoods.FUEL_METAL_STICK));
    public static final Item MINERAL_COAL = new Item(new FabricItemSettings());
    public static final Item MINERAL_CHARCOAL = new Item(new FabricItemSettings());
    public static final Item MINERAL_FUEL_METAL = new Item(new FabricItemSettings());
    public static final Item CROP_FUEL_METAL = new Item(new FabricItemSettings().food(ModFoods.FUEL_METAL));
    // 铜食物
    public static final Item COPPER_APPLE = new Item(new FabricItemSettings().rarity(Rarity.RARE).food(ModFoods.COPPER_APPLE));
    public static final Item COPPER_BREAD = new Item(new FabricItemSettings().food(ModFoods.COPPER_BREAD));
    public static final Item COPPER_CARROT = new Item(new FabricItemSettings().food(ModFoods.COPPER_CARROT));
    public static final StewItem COPPER_HODGEPODGE = new StewItem(new FabricItemSettings().maxCount(1).food(ModFoods.COPPER_HODGEPODGE));
    public static final Item COPPER_KELP = new Item(new FabricItemSettings().food(ModFoods.COPPER_KELP));
    public static final Item COPPER_MELON_SLICE = new Item(new FabricItemSettings().food(ModFoods.COPPER_MELON));
    public static final Item COPPER_POTATO = new Item(new FabricItemSettings().food(ModFoods.COPPER_POTATO));
    public static final Item ENCHANTED_COPPER_APPLE = new EnchantedGoldenAppleItem(new FabricItemSettings().rarity(Rarity.EPIC).food(ModFoods.ENCHANTED_COPPER_APPLE));
    // 紫水晶与锡
    public static final Item AMETHYST_INGOT = new Item(new FabricItemSettings());
    public static final Item TIN_INGOT = new Item(new FabricItemSettings());
    public static final Item RAW_TIN = new Item(new FabricItemSettings());
    public static ShovelItem AMETHYST_SHOVEL = new ShovelItem(ModToolMaterials.AMETHYST, 5F, -3.0F, new Item.Settings());
    public static SwordItem AMETHYST_BOARDSWORD = new SwordItem(ModToolMaterials.AMETHYST, 6, -3.0F, new Item.Settings());
    public static PickaxeItem AMETHYST_PICKAXE = new PickaxeItem(ModToolMaterials.AMETHYST, 5, -3.0F, new Item.Settings());
    public static AxeItem AMETHYST_AXE = new AxeItem(ModToolMaterials.AMETHYST, 7F, -3.0F, new Item.Settings());
    public static HoeItem AMETHYST_HOE = new HoeItem(ModToolMaterials.AMETHYST, 5, -3.0F, new Item.Settings());
    
    public static void register() {
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_coin"), COPPER_COIN);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "diamond_coin"), GOLD_COIN);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "gold_coin"), DIAMOND_COIN);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "fuel_metal"), FUEL_METAL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "nightmare_fuel_metal"), NIGHTMARE_FUEL_METAL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "fuel_metal_stick"), FUEL_METAL_STICK);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "mineral_coal"), MINERAL_COAL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "mineral_charcoal"), MINERAL_CHARCOAL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "mineral_fuel_metal"), MINERAL_FUEL_METAL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "crop_fuel_metal"), CROP_FUEL_METAL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_apple"), COPPER_APPLE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_bread"), COPPER_BREAD);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_carrot"), COPPER_CARROT);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_hodgepodge"), COPPER_HODGEPODGE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_kelp"), COPPER_KELP);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_melon_slice"), COPPER_MELON_SLICE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "copper_potato"), COPPER_POTATO);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "enchanted_copper_apple"), ENCHANTED_COPPER_APPLE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_ingot"), AMETHYST_INGOT);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "tin_ingot"), TIN_INGOT);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_shovel"), AMETHYST_SHOVEL);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_boardsword"), AMETHYST_BOARDSWORD);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_pickaxe"), AMETHYST_PICKAXE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_axe"), AMETHYST_AXE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "amethyst_hoe"), AMETHYST_HOE);
        Registry.register(Registries.ITEM, new Identifier(HiddenYears2.MOD_ID, "raw_tin"), RAW_TIN);
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(content -> {
            content.addAfter(Items.IRON_SWORD,AMETHYST_BOARDSWORD);
        	content.add(COPPER_COIN);
            content.add(DIAMOND_COIN);
            content.add(GOLD_COIN);
        });
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(content -> {
            content.add(AMETHYST_INGOT);
            content.add(TIN_INGOT);
            content.addAfter(Items.RAW_IRON,RAW_TIN);
        });
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(content -> {
            content.add(COPPER_APPLE);
            content.add(COPPER_BREAD);
            content.add(COPPER_CARROT);
            content.add(COPPER_HODGEPODGE);
            content.add(COPPER_KELP);
            content.add(COPPER_MELON_SLICE);
            content.add(COPPER_POTATO);
            content.add(ENCHANTED_COPPER_APPLE);
        });
        ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(content -> {
        	content.addAfter(Items.IRON_HOE,AMETHYST_SHOVEL);
        	content.addAfter(AMETHYST_SHOVEL,AMETHYST_PICKAXE);
        	content.addAfter(AMETHYST_PICKAXE,AMETHYST_AXE);
        	content.addAfter(AMETHYST_AXE,AMETHYST_HOE);
        });
        FuelRegistry.INSTANCE.add(FUEL_METAL_STICK, 250);
        FuelRegistry.INSTANCE.add(MINERAL_COAL, 900);
        FuelRegistry.INSTANCE.add(MINERAL_CHARCOAL, 400);
        FuelRegistry.INSTANCE.add(MINERAL_FUEL_METAL, 1000);
        FuelRegistry.INSTANCE.add(CROP_FUEL_METAL, 300);
    }
}